<html>

<body>
    <input type="file" id='imgup'>
    <button id='sub' type="button">提交</button>
    <script src="../libs/jquery-3.5.1.min.js"></script>
    <script>
        $(function () {
            $("#sub").click(() => {
                var form = new FormData();
                var files = $('#imgup');
                // $.each(files,
                //     function (i, e) {
                //         console.log($(e).parent().parent().find("input[type=hidden]"));
                //         var bid = $(e).parent().parent().find("input[type=hidden]").val();
                //         formData.append($(e).attr("name") + "_" + bid, e.files[0]);
                //     });
                form.append("file", $("#imgup")[0].files[0]);
                $.ajax({
                    url: 'http://localhost:8080/image/upload',
                    type: 'POST',
                    data: form,
                    processData: false,
                    contentType: false,
                    cache: false,
                    success: function (res) {
                        console.log(res);
                    }
                })
            });
        });

    </script>
</body>

</html>